import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  Query,
} from '@nestjs/common'
import { TopicService } from './topic.service'
import { CreateTopicDto } from './dto/create-topic.dto'
import { UpdateTopicDto } from './dto/update-topic.dto'
import { ApiTags, ApiOperation } from '@nestjs/swagger/dist'
@Controller('topic')
@ApiTags('话题圈子相关接口')
export class TopicController {
  constructor(private readonly topicService: TopicService) {}

  @Post()
  @ApiOperation({ summary: '创建话题圈子' })
  create(@Body() createTopicDto: CreateTopicDto) {
    return this.topicService.create(createTopicDto)
  }

  @Get('keywords')
  @ApiOperation({ summary: '根据关键词模糊搜索' })
  findByNameLike(@Query() query: { keyword: string }) {
    return this.topicService.findByNameLike(query)
  }
  @Get()
  findAll() {
    return this.topicService.findAll()
  }

  @Get(':id')
  findOne(@Param('id') id: string) {
    return this.topicService.findOne(id)
  }

  @Patch(':id')
  update(@Param('id') id: string, @Body() updateTopicDto: UpdateTopicDto) {
    return this.topicService.update(+id, updateTopicDto)
  }

  @Delete(':id')
  remove(@Param('id') id: string) {
    return this.topicService.remove(+id)
  }
}
